import { Global, Module } from '@nestjs/common';
import { MinioClientController } from './MinioClient.controller';
import { MinioModule } from 'nestjs-minio-client';
import { ConfigService } from '@nestjs/config';
import { MinioClientService } from './MinioClient.service';

@Global()
@Module({
  imports: [
    MinioModule.registerAsync({
      inject: [ConfigService],
      useFactory: (config: ConfigService) => {
        return {
          endPoint: config.get('minio.endpoint'),
          port: config.get('minio.port'),
          useSSL: false,
          accessKey: config.get('minio.access_key'),
          secretKey: config.get('minio.secret_key'),
        };
      },
    }),
  ],
  controllers: [MinioClientController],
  providers: [MinioClientService],
  exports: [MinioClientService],
})
export class MinioClientModule {}
